package router

import (
	"github.com/gin-gonic/gin"
	"github.com/tycme/gin-chat/middlewares"
	"github.com/tycme/gin-chat/service"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.Static("/static", "./views")
	r.Static("/image", "./views/image")
	r.Static("/asset", "/asset/")
	r.StaticFile("/favicon.ico", "asset/images/favicon.ico")
	r.LoadHTMLGlob("views/**/*")
	r.GET("/", service.ToIndex)
	r.GET("/index", service.ToIndex)
	r.GET("/toRegister", service.ToRegister)

	//上面是静态页面

	r.POST("/login", service.Login)
	r.POST("/send/code", service.SendCode)
	//r.GET("/insertManyUserRoom", service.InsertManyUserRoom)
	//下面是测试
	r.GET("/clientDemo", service.ClientDemo)
	r.GET("/insertManyRegister", service.InsertManyRegister) //生成测试数据
	r.POST("/register", service.Regiseter)
	r.GET("/getReport", service.GetReport)
	r.GET("/client", service.GetClientLength)
	r.GET("/sendToAllClient", service.SendToAllClient)

	//上面是测试
	//r.POST("/user/add", service.UserAdd)
	auth := r.Group("/u", middlewares.AuthCheck())
	auth.GET("/toChat", service.ToChat)
	auth.POST("/user/detail", service.UserDetail)
	auth.GET("/user/query", service.UserQuery)
	//
	auth.GET("/websocket/message", service.WebsocketMessage)
	auth.GET("/chat/list", service.ChatList)                         //聊天内容
	auth.GET("/user/findFriendsList", service.FindFriendsList)       //加好朋友
	auth.GET("/userRoom/findUserList", service.FindUserListByRoomID) //加好朋友
	auth.POST("/user/joinFriends", service.JoinFriends)              //加好朋友
	auth.DELETE("/user/delete", service.Delete)
	return r
}
